package com.ygqh.baby.service;

import com.ygqh.baby.ao.*;
import com.ygqh.baby.model.BaseSkuInfo;
import com.ygqh.baby.model.ShoppingCarBasicData;
import com.ygqh.baby.model.YgPtSkuInfo;
import com.ygqh.baby.model.YgShoppingCarModel;
import com.ygqh.baby.po.YgShoppingCar;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface YgShoppingCarService {

    List<YgShoppingCar> find(Long userId);

    int findCount(Long userId);

    YgShoppingCar findById(Long id);

    int deleteSoft(Long[] ids, Long userId);

    int deleteSoft(Long id, Long userId);

    int update(YgShoppingCar ygShoppingCar);

    ResultSet<YgShoppingCar> search(QueryInfo queryInfo, String q);

    int removeShoppingCar(Long userId);

    int updateNum(Long skuId, Boolean isAdd, Long userId, SalesPlatform salesPlatform);

    YgShoppingCar findBySkuId(Long skuId, PromotionType pType, Long userId);

    /**
     * 根据skuid 查询当前用户购物车列表
     *
     * @param skuIds
     * @param pType
     * @param userId
     * @return
     */
    List<YgShoppingCar> findBySkuIds(Long[] skuIds, PromotionType pType, Long userId);

    YgShoppingCar findBySkuIdWithSku(Long skuId, PromotionType pType, Long userId);

    /**
     * 根据skuid 查询当前用户购物车列表(含sku售价)
     *
     * @param skuIds
     * @param pType
     * @param userId
     * @return
     */
    List<YgShoppingCar> findBySkuIdsWithSku(Long[] skuIds, PromotionType pType, Long userId);

    /**
     * 获取当前用户购物车列表 按库存排序
     */
    List<YgShoppingCarModel> findShoppingCarList(QueryInfo queryInfo, Long userId, Boolean distribution);

    int removeShoppingCar(Long userId, SalesPlatform salesPlatform);

    List<YgShoppingCarModel> findShoppingCarList(QueryInfo queryInfo, Long userId);

    List<YgShoppingCarModel> findShoppingCarList(QueryInfo queryInfo, Long userId, Boolean distribution,
                                                 SalesPlatform salesPlatform);

    /**
     * 添加赠品到购物车
     *
     * @param skuId
     * @param quantity
     * @param userId
     * @param pType
     * @param promotionPrice
     * @return
     */
    Message addPromotionItem(Long skuId, Long quantity, Long userId, PromotionType pType, BigDecimal promotionPrice);

    Message addPromotionItem(Long skuId, Long quantity, Long userId, PromotionType pType,
                             BigDecimal promotionPrice, SalesPlatform salesPlatform);

    /**
     * 添加普通商品到购物车
     *
     * @param skuId
     * @param quantity
     * @param userId
     * @return
     */
    int addOrdinaryItem(Long skuId, Long quantity, Long userId);

    int addOrdinaryItem(Long skuId, Long quantity, Long userId, SalesPlatform salesPlatform);

    /**
     * 更新购物车商品数量
     *
     * @param skuId
     * @param isAdd
     * @param userId
     * @return
     */
    int updateNum(Long skuId, Boolean isAdd, Long userId);

    /**
     * 获取已选中的商品
     *
     * @param userId
     * @return
     */
    @Deprecated
    List<YgShoppingCarModel> findIsCheck(Long userId, Boolean distribution);

    @Deprecated
    List<YgShoppingCarModel> findIsCheck(Long userId);

    List<YgShoppingCarModel> findIsCheck(Long userId, Boolean distribution, SalesPlatform salesPlatform);

    /**
     * 更新选中
     *
     * @param carList
     * @return
     */
    int updateCarForCheck(Long[] skuIds, Long userId);

    int findItemCount(Long userId, SalesPlatform salesPlatform);

    /**
     * 删除已选中
     *
     * @param carList
     * @param salesPlatform
     * @return
     */
    int deleteCarByCheck(Long userId, SalesPlatform salesPlatform);

    int updateCarForCheck(Long[] skuIds, Long userId, SalesPlatform salesPlatform);

    /**
     * 获取购物车中商品总数量
     *
     * @param userId
     * @return
     */
    int findItemCount(Long userId);

    YgShoppingCarModel findShoppingCarById(Long carId);

    List<List<YgShoppingCarModel>> sortCarList(List<YgShoppingCarModel> list, Long userId);

    List<List<YgShoppingCarModel>> sortCarListV2(List<YgShoppingCarModel> list, Long userId);

    Map<Long, List<YgShoppingCarModel>> sortCarMapV2(List<YgShoppingCarModel> list, Long userId);

    /**
     * 同一花色，只有一件新客商品享受新客价
     *
     * @param carList
     */
    void doNewCusBussness(List<YgShoppingCarModel> carList);

    /**
     * 判断购物车中是存在同一花色下多个新客商品
     *
     * @param skuId
     * @return
     */
    Boolean hasOtherNewCus(Long skuId, Long userId);

    List<YgShoppingCarModel> findItemInfoPt(List<YgPtSkuInfo> skuList, Long userId);

    List<YgShoppingCarModel> findItemInfoPt(List<YgPtSkuInfo> skuList, Long userId, Boolean distribution);

    List<YgShoppingCarModel> findItemInfoPt(List<YgPtSkuInfo> skuList, Long userId, Boolean distribution,
                                            SalesPlatform salesPlatform);

    List<YgShoppingCarModel> findItemInfo(List<BaseSkuInfo> skuList, Long userId);

    /**
     * 根据已知的sku信息，组成购物车信息
     *
     * @param skuList
     * @param userId
     * @param promotionType
     * @return
     */
    List<YgShoppingCarModel> findItemInfo(List<BaseSkuInfo> skuList, Long userId, PromotionType promotionType);

    List<YgShoppingCarModel> findItemInfo(List<BaseSkuInfo> skuList, Long userId, PromotionType promotionType, Boolean distribution);

    List<YgShoppingCarModel> findItemInfo(List<BaseSkuInfo> skuList, Long userId, PromotionType promotionType,
                                          Boolean distribution, SalesPlatform salesPlatform);

    List<YgShoppingCarModel> findShoppingCarListBySkuIds(Long[] skuIds, Long userId, Boolean distribution);

    List<YgShoppingCarModel> findShoppingCarListBySkuIds(Long[] skuIds, Long userId, Boolean distribution,
                                                         SalesPlatform salesPlatform);

    List<ShoppingCarBasicData> findCarBasicDataList(Long userId, SalesPlatform salesPlatform);

    List<ShoppingCarBasicData> findCarBasicDataListBySkuId(Long userId, PromotionType salesType, List<Long> skuList);
}
